import { Context } from 'koa';
import { KoaMiddlewareInterface } from 'routing-controllers';

/**
 * 局部中间件
 */
export class AuthMiddleware implements KoaMiddlewareInterface {
  async use(context: Context, next: (err?: any) => Promise<any>): Promise<any> {
    const { request, response } = context;
    const token = context.cookies.get('login_auth') || request.header['authorization'];
    console.log(token);
    await next();
  }
}

export class LoggerMiddleware implements KoaMiddlewareInterface {
  async use(context: Context, next: (err?: any) => Promise<any>): Promise<any> {
    await next();
  }
}